/**
 * Copyright (c) Tiny Technologies, Inc. All rights reserved.
 * Licensed under the LGPL or a commercial license.
 * For LGPL see License.txt in the project root for license information.
 * For commercial licenses see https://www.tiny.cloud/
 *
 * Version: 5.8.2 (2021-06-23)
 */
(function () {
  'use strict';
  tinymce.PluginManager.add('formula', function (editor) {
    // 注册一个工具栏按钮名称
    // 公式编辑
    var baseURL = "editorLib/formula/index.html"
    var openDialog = function () {
      return editor.windowManager.openUrl({
        title: '插入公式',
        size: 'large',
        width: 800,
        height: 620,
        url: baseURL,
        buttons: [
          {
            type: 'cancel',
            text: 'Close'
          },
          {
            type: 'custom',
            text: 'Save',
            name: 'save',
            primary: true
          },
        ],
        onAction: function (api, details) {
          switch (details.name) {
            case 'save':
              api.sendMessage("save");
              break;
            default:
              break;
          };
        }
      });
    };
    editor.ui.registry.addButton('formula', {
      icon: 'icon-fuhao',
      tooltip: 'Insert formula',
      onAction: function () {
        openDialog()
      }
    });
  });

}());
